<template>
  <!-- //用来设置属性 效果 -->
  <div class="about_max_box">
    <div class="about_boox" v-show="show" @click="showSwiper">
      <img :src="list.bannerImg" width="100%" />
    </div>

    <!-- 过度 -->
    <FadeAnimation>
      <div class="about_box_swiper" v-show="!show" @click="angShow">
        <swiper :options="swiperOptions">
          <swiper-slide class="classify_item" v-for="(item,index) in list.gallaryImgs" :key="index">
            <img :src="item" width="100%" class="about_box_image" />
          </swiper-slide>
          <!-- 小圆点 -->
          <div class="swiper-pagination" slot="pagination"></div>
        </swiper>
      </div>
    </FadeAnimation>
    <div class="iconfont back_up" @click="gotoup" v-show="isSHow">&#xe60d;</div>
    <div class="about_header_box" v-show="!showhash" :style="opacityStyle">
      <div class="iconfont back_">&#xe60d;</div>
      <div>故宫</div>
      <div></div>
    </div>
    <Details :category="category" :isSHow="isSHow"></Details>
  </div>
</template>

<script>
import axios from "axios";
import Details from "./Details";
import FadeAnimation from "../common/FadeAnimation";
export default {
  components: {
    Details,
    FadeAnimation,
  },
  data() {
    return {
      //和上面绑定的一致
      // category:[],
      swiperOptions: {
        pagination: ".swiper-pagination",
        paginationType: "fraction",
        observeParents: true, //Swiper更新
        observer: true,
      },
      show: true,
      list: [],
      isSHow: true,
      showhash: true,
      opacityStyle: {
        opacity: 0,
      },
      // styleobj:{

      // }
    };
  },
  mounted() {
    let id = this.$route.query.id;
    console.log(id);
    axios.get("./static/detail.json").then((res) => {
      // console.log(res.data.data);
      this.list = res.data.data;
      this.category = res.data.data.categoryList;
      console.log(this.category);
    });
  },
  methods: {
    showSwiper() {
      this.show = !this.show;
      this.isSHow = false;
    },
    angShow() {
      this.show = !this.show;
      this.isSHow = true;
    },
    gotoup() {
      window.history.back();
    },
    handleScroll() {
      const top = document.documentElement.scrollTop;
      // console.log(document.documentElement.scrollTop);
      if (top > 58) {
        let opacity = top / 140;
        opacity = opacity > 1 ? 1 : opacity;
        this.opacityStyle = { opacity };
        this.showhash = false;
      } else {
        this.showhash = true;
      }
    },
  },
  // 全局事件绑定
  activated() {
    window.addEventListener("scroll", this.handleScroll);
  },
  deactivated() {
    window.removeEventListener("scroll", this.handleScroll);
  },
};
</script>

<style>
.about_box_swiper {
  width: 100%;
  height: 667px;
  background: rgba(0, 0, 0, 1);
  position: fixed;
  /* margin-top: 0.89rem; */
}
.about_box_image {
  margin-top: 38.5%;
}
/* .about_boox{
  margin-top: 0.99rem;
} */
.back_up {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  position: absolute;
  top: 0.05rem;
  text-align: center;
  line-height: 0.6rem;
  color: white;
  left: 0.05rem;
  font-weight: lighter;
}
.swiper-pagination {
  color: white;
}
.about_header_box {
  display: flex;
  line-height: 1rem;
  background: #00bcd4;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  justify-content: space-between;
}
.about_max_box {
  height: 900px;
}
.back_ {
  /* width: 0.6rem; */
  /* height: 0.6rem; */
  margin-left: 0.19rem;
  box-sizing: border-box;
}
</style>